﻿// *----------------------------------------------------------------
// Copyright (C) 2017 通通优品
// 版权所有。
// 
// 类名：StartupConfiguration.cs
// 功能描述：TongTongMall
// 
// Create User：jym 2017/02/09
// 
// Edit User：UserName,EditTime
// Describe：Describe
// ----------------------------------------------------------------*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TongTongMall.Dependecy;
using TongTongMall.Domain.Uow;
using TongTongMall.Runtime.Caching.Configuration;

namespace TongTongMall.Configuration.Startup
{
    public class StartupConfiguration : DictionaryBasedConfig, IStartupConfiguration
    {
        /// <summary>
        /// Ioc容器
        /// </summary>
        public IIocManager IocManager { get; private set; }

        /// <summary>
        /// Setting配置
        /// </summary>
        public ISettingsConfiguration Settings { get; private set; }

        /// <summary>
        /// 每个模块的预配置
        /// </summary>
        public IModuleConfigurations Modules { get; private set; }

        /// <summary>
        /// unitofwork 默认配置
        /// </summary>
        public IUnitOfWorkDefaultOptions UnitOfWork { get; private set; }

        /// <summary>
        /// 缓存配置信息
        /// </summary>
        public ICachingConfiguration Caching { get; private set; }

        public StartupConfiguration(IIocManager iocManager)
        {
            IocManager = iocManager;
        }

        /// <summary>
        /// 启动内容默认初始化
        /// </summary>
        public void Initialize()
        {
            Settings = IocManager.Resolve<ISettingsConfiguration>();
            Modules = IocManager.Resolve<IModuleConfigurations>();
            UnitOfWork = IocManager.Resolve<IUnitOfWorkDefaultOptions>();
            Caching = IocManager.Resolve<ICachingConfiguration>();
        }
    }
}
